<?php
set_time_limit(0);
if (isset($_POST['op']) && isset($_POST['n'])){
    include '../c/config.php';
    $openid=addslashes(trim($_POST['op']));
    $name=addslashes(trim($_POST['n']));
    $school=addslashes(trim($_POST['s']));
    $phone=addslashes(trim($_POST['p']));
    $idcard=addslashes(trim($_POST['idc']));
    $rand=rand(1,3);
    if(1 == $rand){
        $dbhost='121.41.216.144';
    }
    if(2 == $rand){
        $dbhost='121.41.221.25';
    }
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
    $queryJ=$mysqli->query("SELECT id from `uf` where op='".$openid."' limit 0,1 ");
    if($queryJ->num_rows>0){

    }else{
        $mysqli->query("INSERT INTO `uf` (`id`,`openid`,`name`,`school`,`phone`,`idcard`,`createtime`) VALUES (NULL,'".$openid."', '".$name."','".$school."','".$phone."','".$idcard."','".date("Y-m-d H:i:s")."')");
    }
    $mysqli->close();
    echo json_encode(array('s'=>'y'));
}else{
    echo json_encode(array('s'=>'n'));
}

?>